package com.worthtech.billportal.web.listener;

import java.io.File;

import javax.servlet.http.HttpServlet;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.worthtech.billportal.util.Constant;
import com.worthtech.billportal.util.SendMsg;
import com.worthtech.socket.server.BlockServer;


/**
 * <p>
 * Title: yangyang ServiceCenter
 * </p>
 * 
 * <p>
 * Description: ServiceCenter
 * </p>
 * 
 * <p>
 * Copyright: Copyright (c) 2006
 * </p>
 * 
 * <p>
 * Company: cardinfo
 * </p>
 * 
 * @author yangyang
 * @version 2.21
 */
public class SysListener extends HttpServlet implements ServletContextListener {
	private static final Log logger = LogFactory.getLog(SysListener.class);
	public  static SendMsg send;
    public void contextInitialized(ServletContextEvent sce) {
        String rootpath = sce.getServletContext().getRealPath("/");
        if (rootpath != null) {
            rootpath = rootpath.replaceAll("\\\\", "/");
        } else {
            rootpath = "/";
        }
        if (!rootpath.endsWith("/")) {
            rootpath = rootpath + "/";
        }
        Constant.ROOTPATH = rootpath;
//        send  = new SendMsg();
        //Constant.CONFIGPATH = rootpath+"WEB-INF/classes/";
//        try	{
//        	BlockServer.load(rootpath+"WEB-INF"+File.separator+"BillServerConfig.xml");
//		} catch(Exception e) {
//			e.printStackTrace();
//		}
    }

    public void contextDestroyed(ServletContextEvent sce) {
        //BoardLoadThread.getInstance(sce.getServletContext()).setIsRun(false);
        //BoardLoadThread.getInstance(sce.getServletContext()).destroy();
        //aTimer.cancel();
        //AppContext.getInstance().getAppContext().close();
    }
}
